TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../../config.mk

# Inputs
SUBGROUP_MODELS := $(TASK_DIR)/../../run_regressions/output/regression_output__by_subgroup.csv
SUBGROUP_FWER := $(TASK_DIR)/../../compute_multiple_hypothesis_adjustment/output/subgroups__multiple_outcomes__main_outcomes.csv
INDEX_SUBGROUP_FWER := $(TASK_DIR)/../../compute_multiple_hypothesis_adjustment/output/full_sample__multiple_subgroups__index_outcome.csv
CONFIG_FILE := $(TASK_DIR)/hand/config.yaml

# One of the outputs
OUT_FILE := $(OUT_DIR)/outcomes_subgroup_ftests_up_to_date.tex

$(OUT_FILE): $(RMD_FILE) $(CONFIG_FILE) $(SUBGROUP_MODELS) $(SUBGROUP_FWER) $(TASK_FNS)
	@mkdir -p $(OUT_DIR)
	@mkdir -p $(PAPER_OUT_DIR)
	$(R_script) -e "rmarkdown::render(input = '$(RMD_FILE)')"
	@cp $(OUT_DIR)/*up_to_date.tex $(PAPER_OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_FILE)

clean:
	rm -rf $(OUT_DIR)/*up_to_date*
